<?php
$errors         = array();              // array to hold validation errors
$data 		= array(); 		// array to pass back data
        // validate the variables ======================================================
	// if any of these variables don't exist, add an error to our $errors array

	if (empty($_POST['country'])){
		$errors['country'] = 'Country is required.';
        }

	if (empty($_POST['memberEmail'])){
		$errors['memberEmail'] = 'Member Email is required.';
        }

	if (empty($_POST['orderID'])){
		$errors['orderID'] = 'Order ID is required.';
        }
        
        if (empty($_POST['skuID'])){
		$errors['skuID'] = 'SKU ID is required.';
        }

	if (empty($_POST['returnValue'])){
		$errors['returnValue'] = 'Return Value is required.';
        }

	if (empty($_POST['returnReason'])){
		$errors['returnReason'] = 'Return Reason is required.';
        }

// return a response ===========================================================

	// if there are any errors in our errors array, return a success boolean of false
	if ( ! empty($errors)) {
                // if there are items in our errors array, return those errors
		$data['success'] = false;
		$data['errors']  = $errors;
	} else {

		// if there are no errors process our form, then return a message

		// DO ALL YOUR FORM PROCESSING HERE
                // 
                // 
                // 
		// THIS CAN BE WHATEVER YOU WANT TO DO (LOGIN, SAVE, UPDATE, WHATEVER)

		// show a message of success and provide a true success variable
		$data['success'] = true;
		$data['message'] = 'Success!';
	}
	// return all our data to an AJAX call
	echo json_encode($data);
